package cn.iocoder.yudao.module.promotion.controller.app.prizedraw;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.promotion.controller.admin.prizedraw.vo.PrizeDrawSettingRespVO;
import cn.iocoder.yudao.module.promotion.controller.app.prizedraw.vo.PrizeDrawExchangeReqVO;
import cn.iocoder.yudao.module.promotion.service.prizedraw.PrizeDrawNumberRecordService;
import cn.iocoder.yudao.module.promotion.service.prizedraw.PrizeDrawSettingService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;


@Tag(name = "用户 APP - 抽奖配置及兑换")
@RestController
@RequestMapping("/promotion/prize-setting")
@Validated
public class AppPrizeDrawSettingController {
    @Resource
    private PrizeDrawNumberRecordService prizeDrawNumberRecordService;

    @Resource
    private PrizeDrawSettingService prizeDrawSettingService;

    @Operation(summary = "查询抽奖设置详情信息")
    @GetMapping("/getPrizeDrawSettingInfo")
    public CommonResult<PrizeDrawSettingRespVO> getPrizeDrawSettingInfo() {
        return success(prizeDrawSettingService.getPrizeDrawSettingInfo());
    }

    @Operation(summary = "积分兑换")
    @GetMapping("/dragonExchange")
    public CommonResult<Boolean> dragonExchange() {
        PrizeDrawExchangeReqVO dto = new PrizeDrawExchangeReqVO();
        dto.setMemberId(getLoginUserId());
        //TODO
        //prizeDrawNumberRecordService.exchange(dto);
        return success(true);
    }

    @Operation(summary = "龙豆总额")
    @GetMapping("/dragonTotal")
    public CommonResult<Long> dragonTotal() {
        return success(prizeDrawSettingService.dragonTotal());
    }

}
